#overall_plots
#data prep for response quality plots


##for main text plot (combined surveys and avg coefficients across tests)

##arrange order for plot here:
input1 <- c2.reg13
input2 <- c2.reg2
input3 <- c2.reg3
input4 <- c2.reg1i 
input5 <- c.effort.out
input6 <- c2.reg12
input7 <- c.quality.out
input8 <- c2.reg14
input9 <- c2.reg9
input10 <- c2.reg6
input11 <- c.att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(4,8,10)

#function for standardized regressions
my.fun <- function(fit){
  as.data.frame(std_beta(fit, type = "std", ci.lvl = 0.95)[1, ] )
  }


frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11))
  
for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
frame$std.estimate[i] <-  frame$std.estimate[i] * -1
newhigh <- frame$conf.low[i] * -1
newlow <- frame$conf.high[i] * -1
frame$conf.low[i] <- newlow
frame$conf.high[i] <- newhigh
}


names_avgs <- c( "answering open-ended items", "reading prompt", "answering short items", "straightlining" , "response effort", "response length", "response quality",  "commital answers", "consistency", "skipping", "attention check" )
dimension_avgs <- c("time investment", "time investment", "time investment","straightlining", "open-ended", "open-ended", "open-ended", "commital",  "consistency", "skipping" , "attention check" )
order_avgs <- 1:11
betas_avgs<- cbind(dimension_avgs, names_avgs, order_avgs, frame)



##for appendix plot (separate out different surveys)

##arrange order for plot here:
input1 <- c2.reg5
input2 <- c2.reg4
input3 <- c2.reg2
input4 <-  c2.reg3
input5 <- c2.reg1i 
input6 <- c.effort.out
input7 <- c2.reg11 
input8 <- c2.reg10
input9 <- c.quality.out
input10 <- c2.reg8
input11 <- c2.reg7
input12 <- c2.reg9
input13 <- c2.reg6
input14 <- c.att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(5, 10, 11, 13)

frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11), my.fun(input12), my.fun(input13), my.fun(input14))

for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
  frame$std.estimate[i] <-  frame$std.estimate[i] * -1
  newhigh <- frame$conf.low[i] * -1
  newlow <- frame$conf.high[i] * -1
  frame$conf.low[i] <- newlow
  frame$conf.high[i] <- newhigh
}

names <- c( "answering open-ended 2", "answering open-ended 1", "reading prompt", "answering short items", "straightlining", "response effort", "question 2 length", "question 1 length" , "response quality",  "question 2 answer",  "question 1 answer", "consistency", "skipping", "attention check" )
dimension <- c("time investment", "time investment", "time investment", "time investment", "straightlining", "open-ended", "open-ended", "open-ended", "open-ended", "commital", "commital", "consistency", "skipping", "attention check")
order <- 1:14
betas<- cbind(dimension, names, order, frame)

#repeat for FEP and Sec versions
##arrange order for plot here:
input1 <- c2.reg5.f
input2 <- c2.reg4.f
input3 <- c2.reg2.f
input4 <-  c2.reg3.f
input5 <- c2.reg1i.f
input6 <- c.effort.out.f
input7 <- c2.reg11.f
input8 <- c2.reg10.f
input9 <- c.quality.out.f
input10 <- c2.reg8.f
input11 <- c2.reg7.f
input12 <- c2.reg9.f
input13 <- c2.reg6.f
input14 <- c.att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(5, 10, 11, 13)

frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11), my.fun(input12), my.fun(input13), my.fun(input14))

for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
  frame$std.estimate[i] <-  frame$std.estimate[i] * -1
  newhigh <- frame$conf.low[i] * -1
  newlow <- frame$conf.high[i] * -1
  frame$conf.low[i] <- newlow
  frame$conf.high[i] <- newhigh
}

betas.f<- cbind(dimension, names, order, frame)


##arrange order for plot here:
input1 <- c2.reg5.s
input2 <- c2.reg4.s
input3 <- c2.reg2.s
input4 <-  c2.reg3.s
input5 <- c2.reg1i.s
input6 <- c.effort.out.s
input7 <- c2.reg11.s
input8 <- c2.reg10.s
input9 <- c.quality.out.s
input10 <- c2.reg8.s
input11 <- c2.reg7.s
input12 <- c2.reg9.s
input13 <- c2.reg6.s
input14 <- c.att.out

#input numbers of regressions that need to be reverse coded here:
reverse.list <- c(5, 10, 11, 13)

frame <- rbind(my.fun(input1), my.fun(input2), my.fun(input3), my.fun(input4), my.fun(input5), 
               my.fun(input6), my.fun(input7), my.fun(input8), my.fun(input9), my.fun(input10),
               my.fun(input11), my.fun(input12), my.fun(input13), my.fun(input14))

for(i in 1:length(reverse.list)){
  i <- reverse.list[i]
  frame$std.estimate[i] <-  frame$std.estimate[i] * -1
  newhigh <- frame$conf.low[i] * -1
  newlow <- frame$conf.high[i] * -1
  frame$conf.low[i] <- newlow
  frame$conf.high[i] <- newhigh
}

betas.s<- cbind(dimension, names, order, frame)
